const utils = require('j7/utils');
const app = require('j7/app');
const db = require('j7/db');
const log = require('j7/log');

class User {

  constructor(session) {
    this.session = session;
    this.accountId = session.request('account_id');
    this.sessionId = session.request('session_id');
    this.useConns = {};
    this.selfDb = null;
  }

  async destory() {
    for (let key in this.useConns) {
      this.useConns[key].release();
    }
    this.useConns = null;
  }

  getAccountId() {
    return this.accountId;
  }

  getChannel() {
    return utils.extractChannel(this.getAccountId());
  }

  getSessionId() {
    return this.sessionId;
  }

  getRegisterTime() {
    return utils.extractRegisterTime(this.getAccountId(), this.getSessionId());
  }

}

exports.User = User;
